package intermediate_representation;

import symbal.Vtype;

import java.util.ArrayList;

public class DefineRP extends InterRP {
    private boolean isconst;
    private Vtype type;
    private String name;
    private int len1;
    private int len2;

    public DefineRP(boolean isconst, String name) {
        this.isconst = isconst;
        this.type = Vtype.INT;
        this.name = name;
    }

    public DefineRP(boolean isconst, String name, int len1) {
        this.isconst = isconst;
        this.type = Vtype.INT1;
        this.name = name;
        this.len1 = len1;
    }

    public DefineRP(boolean isconst, String name, int len1, int len2) {
        this.isconst = isconst;
        this.type = Vtype.INT2;
        this.name = name;
        this.len1 = len1;
        this.len2 = len2;
    }

    public boolean isIsconst() {
        return isconst;
    }

    public Vtype getType() {
        return type;
    }

    public String getName() {
        return name;
    }

    public int getLen1() {
        return len1;
    }

    public int getLen2() {
        return len2;
    }

    public String toString() {
        String str = "";
        if (isconst) {
            str += "const ";
        } else {
            str += "var ";
        }
        if (type.equals(Vtype.INT1)) {
            str += "arr1 int " + name + "[" + len1 + "]";
        } else if (type.equals(Vtype.INT2)) {
            str += "arr2 int " + name + "[" + len1 + "][" + len2 + "]";
        } else {
            str += "int " + name;
        }
        return str;
    }
}
